import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/hello")
public class Hello_World extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html; charset=utf8");
        // 将"hello world" 打印到tomcat服务器控制台上
        System.out.println("你好 world");
        // 将字符串 "hello world”作为 http 响应的body部分
        // 将字符串打印到浏览器页面上
        resp.getWriter().write("你好 world");
    }
}
